SET SERVEROUTPUT ON SIZE 1000000;
SET VERIFY OFF

DECLARE
	l_total_extracted	NUMBER;
	l_total_imported	NUMBER;				
	l_func_id			VARCHAR2(100):='CAPFNDREC_CONC_PROG_FLEX_TL';

BEGIN
	SELECT COUNT(1)
	INTO l_total_extracted        
FROM
		FND_CONCURRENT_PROGRAMS		FCP,
		FND_CONCURRENT_PROGRAMS_TL	FCPT,
		FND_DESCRIPTIVE_FLEXS_TL	FDFT
	WHERE	FCP.Application_ID				=	FCPT.Application_ID
	AND		FCP.Concurrent_Program_ID		=	FCPT.Concurrent_Program_ID
	AND		FCPT.Language					=	'US'
	AND		SUBSTR(FCPT.User_Concurrent_Program_Name,1,4)	=	UPPER('&1')
	AND		FDFT.Application_ID				=	FCP.Application_ID
	AND		FDFT.Descriptive_Flexfield_Name	=	'$SRS$.'||FCP.Concurrent_Program_Name
	ORDER BY
		FDFT.Application_ID,
		FDFT.Descriptive_Flexfield_Name,
		FDFT.Language;
	
	SELECT COUNT(1) 
	INTO l_total_imported
	FROM CRST_FND_CONC_PROG_FLEX_TL;

	dbms_output.put_line('Function: '||l_func_id);		
	dbms_output.put_line('Total Extracted: '||TO_CHAR(l_total_extracted)) ;
	dbms_output.put_line('Total Imported:  '||TO_CHAR(l_total_imported));
	IF l_total_extracted <> l_total_imported THEN
		dbms_output.put_line('Error: No. of Records do not match!');
	END IF;		
						
EXCEPTION
	WHEN OTHERS THEN	
		dbms_output.put_line('Function Error: '||l_func_id);			
END;
/
